package Demo08.Demo0827;

/*  public String name;
  public String gender;
  public int age;
  public double score;
  public static String classRoom = "Bit306";

  public static String getClassRoom(){
      return classRoom;
  }

  public Student(String name,String gender,int age,double score){}
  public static void main(String[] args) {
      //静态成员可以通过类名直接访问
      System.out.println(Student.classRoom);

      Student s1 = new Student("li leilei", "男", 18, 3.8);
      Student s2 = new Student("Han Meimei", "女", 19, 4.0);
      Student s3 = new Student("Jim", "男", 18, 2.6);

      //也可以通过对象名调用，但是三个对象共享这个classRoom
      System.out.println(s1.classRoom);
      System.out.println(s2.classRoom);
      System.out.println(s3.classRoom);
  }        */
 /*   public String name;
    public String gender;
    public int age;
    public double score;

    //这是一个实例代码块
    public Student(){
        System.out.println("I am Student init()!");
    }

    //这是一个啥代码块呀？  普通代码块
    {
        this.name = "bit";
        this.age = 12;
        this.gender = "man";
        System.out.println("I am instance init()!");
    }

    // 这是一个成员方法
    public void show(){
        System.out.println("name:" + name + "age:" + age + "gender:" + gender);
    }


    public static void main(String[] args) {
        Student p1 = new Student();
        p1.show();
    }
*/  //测试实例代码块
//用来测试构造代码块
public class Student{
        private String name;
        private String gender;
        private int age;
        private double score;
        private static String classRoom;

        //实例代码块
        {
            this.name = "bit";
            this.age = 12;
            this.gender = "man";
            System.out.println("I am instance init()!");
        }

        //静态代码块
        static{
            classRoom = "bit306";
            System.out.println("I am static init()!");
        }

        public Student(){
            System.out.println("I am Student init()!");
        }//构造方法

    public static void main(String[] args) {
        Student s1 = new Student();
        Student s2 = new Student();
    }
}
